package com.pojoin.cms.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

public class SpringContext implements BeanFactoryAware {

	public static BeanFactory beanFactory;

	private SpringContext() {
	}

	@SuppressWarnings("static-access")
	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.beanFactory = beanFactory;
	}

	public static Object getBean(String name) {
		return beanFactory.getBean(name);
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(String name, Class<T> clas) {
		return (T) beanFactory.getBean(name);
	}
}
